var arr = [3, 5, 7, 1, 4, 56, 12, 37, 78, 25, 0, 9, 3, 8, 42];
function merge(array) {
  if (array.length < 2) return array;
  const mid = Math.floor(array.length / 2);
  const left = array.slice(0, mid);
  const right = array.slice(mid);
  return mergeArray(merge(left), merge(right));
}
function mergeArray(left, right) {
  const result = [];
  while (left.length > 0 && right.length > 0) {
    if (left[0] > right[0]) {
      result.push(right.shift());
    } else {
      result.push(left.shift());
    }
  }
  while (left.length) {
    result.push(left.shift());
  }
  while (right.length) {
    result.push(right.shift());
  }
  return result;
}
console.log(merge(arr));
